﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using JsonTest1.CControl;
using JsonTest1.NetEngine;
using JsonTest1.Net;
using System.IO;
using JsonTest1.Data;
using JsonTest1.Configure;

namespace JsonTest1.Pivot
{
    public partial class SpinnerMain : PhoneApplicationPage,IHttpStateListener
    {

        private static int[] recommended_ids = {
		9, // rock
		4, // dance
		5, // hiphop
		6, // jazz
		7, // lounge
		8, // pop
		283 // metal
	};

        public SpinnerMain()
        {
            InitializeComponent();

            
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {

          /* PopularAlbumsWeekEngine engine= new PopularAlbumsWeekEngine();
           engine.setHttpListener(this);
           engine.Request();*/

          /*  RadiosEngine engine= new RadiosEngine();
           engine.setHttpListener(this);
           engine.Request(recommended_ids);*/

         /*   Top100Engine engine = new Top100Engine();
            engine.setHttpListener(this);
            engine.Request();*/

        /*    SearchForAlbums engine = new SearchForAlbums();
            engine.setHttpListener(this);
            engine.Request(Constants.Album_Type.Album_Type_Artist, "");*/

            UserPlaylistEngine engine = new UserPlaylistEngine();
            engine.setHttpListener(this);
            engine.Request("");
        }


       public void HttpFailCalback(int failType, int errorType,ResultData data) { }
       public void HttpDataStreamCalback(Stream stream, ResultData data)
       {

           // Album[] albums = (Album[])data.RData;
           //Radio[] albums = (Radio[])data.RData;
           PlaylistRemote[] albums = (PlaylistRemote[])data.RData;

            List<People> lists = new List<People>();
            for (int i = 0; i < albums.Length; i++)
            {
                 People p = new People();
                /* p.Name = "" + albums[i].Name;
                 p.Value = "" + albums[i].Rating;
                 p.Sample = "" + albums[i].Tracks;

               /*  p.Name = "" + albums[i].Image;
                 p.Value = "" + albums[i].Idstr;
                 p.Sample = "" + albums[i].Name;*/

                 p.Name = "" + albums[i].Id;
                 p.Value = "" + albums[i].Name;
                 p.Sample = "" + albums[i].Duration;


                 lists.Add(p);

            }
            spinner.setTitle(null);
            spinner.setResource(lists);
        }
       public void HttpProgressChangedCalback(int progress, long totalProgress, HTTP_TYPE type) { }
       public void HttpCompleted()
       {

        }
    }
}